{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "#load \"LoadBaseToolWPF.csx\"\n",
    "using BaseTool;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "using System;\n",
    "using System.Runtime.CompilerServices;\n",
    "\n",
    "public void Test([CallerMemberName] string name = \"\")\n",
    "{\n",
    "    Console.WriteLine($\"调用者：{name}\");\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "调用者：MainTest\r\n"
     ]
    }
   ],
   "source": [
    "public void MainTest()\n",
    "{\n",
    "    Test();\n",
    "}\n",
    "\n",
    "MainTest();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`[CallerMemberName]` 方法名称\n",
    "\n",
    "`[CallerFilePath]` 文件路径\n",
    "\n",
    "`[CallerLineNumber]` 代码所在行\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<Initialize>\n",
      "\n",
      "12\n"
     ]
    }
   ],
   "source": [
    "using System.Runtime.CompilerServices;\n",
    "\n",
    "void Test([CallerMemberName] string origin = null,\n",
    "            [CallerFilePath] string callerFile = null,\n",
    "            [CallerLineNumber] int codeLine = 0)\n",
    "{\n",
    "    if (origin != null) Console.WriteLine($\"{origin}\");\n",
    "    if (callerFile != null) Console.WriteLine($\"{callerFile}\");\n",
    "    if (codeLine != 0) Console.WriteLine($\"{codeLine}\");\n",
    "}\n",
    "\n",
    "Test();"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "python"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
